package yannan.voiplock4ble.adapter;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.view.View;


import java.util.List;

import yannan.voiplock4ble.R;
import yannan.voiplock4ble.adapter.base.MyViewHolder;
import yannan.voiplock4ble.adapter.base.RecyclerViewBaseAdapter;

/**
 * <p>name:</p>
 * <p>describe: 添加设备页面 设备列表</p>
 *
 * @author Maintel
 * @time 2016/9/9 15:02
 */
public class AddDevicesAdapter extends RecyclerViewBaseAdapter<BluetoothDevice> {

    public AddDevicesAdapter(List<BluetoothDevice> list, Context ctx) {
        super(list, ctx);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item_search_device;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int poi) {
        BluetoothDevice device = list.get(poi);
        device.getName();
        if (device.getName() != null) {
            holder.setTextView(R.id.tv_lock_name, device.getName());
        }
        holder.setTextView(R.id.tv_lock_address, device.getAddress());
        if (poi == list.size() - 1) {
            holder.get(R.id.bottom_line).setVisibility(View.GONE);
        } else {
            holder.get(R.id.bottom_line).setVisibility(View.VISIBLE);
        }
    }
}
